# 诗文排版器
# 周子阳


# v1.0.0

def readTxt(path):
    with open(path, 'r') as file:
        return file.read()


def writeTxt(path, s):
    with open(path, 'w') as file:
        file.write(s)


oldText = readTxt('静夜思.txt')
newText = ''

for i in range(len(oldText.split(' '))):
    line = oldText.split(' ')[i]
    newText += '{}\n'.format(line)

writeTxt('静夜思-v1.0.0.txt', newText)



# v2.0.0

lines = []
with open('静夜思-v1.0.0.txt', 'r') as f:
    lines = f.readlines()

with open('静夜思-v2.0.0.txt', 'a') as f:
    for i in range(len(lines)):
        if i == 0:
            f.write('  {}'.format(lines[i]))
        elif i==1:
            f.write('唐朝 {}'.format(lines[i]))
        else:
            f.write(lines[i])


# 绝句
lines = []
with open('绝句.txt', 'r') as f:
    lines = f.readlines()
with open('绝句-v1.0.0.txt', 'a') as f:
    j = 0
    for i in lines:
        if i == '\n':
            del lines[j]
        f.write(lines[j])
        j += 1
    
